#include <nvboard.h>
#include <VNvboardTop.h>
#include <memory>

int main() {
    std::unique_ptr<VNvboardTop> dut {new VNvboardTop};
    Verilated::traceEverOn(true);

    nvboard_bind_pin(&dut->io_tx, 1, UART_OUTPUT);
    nvboard_bind_pin(&dut->io_rx, 1, UART_INPUT);

    nvboard_init();

    dut->clock = 0;
    dut->reset = 1;
    dut->eval();
    dut->contextp()->timeInc(1);

    dut->clock = 1;
    dut->reset = 1;
    dut->eval();
    dut->contextp()->timeInc(1);

    dut->clock = 0;
    dut->reset = 0;
    dut->eval();
    dut->contextp()->timeInc(1);

    while (1) {
        dut->clock = 1;
        dut->eval();
        dut->contextp()->timeInc(1);

        nvboard_update();

        dut->clock = 0;
        dut->eval();
        dut->contextp()->timeInc(1);
    }

    nvboard_quit();
    return 0;
}
